var pageSize = 10;
//职称类别
var resourceTypeMap = {};
var applyCodeMap={};
var rowid=null;
$(document).ready(function(){
	//表格初始化
	initTable();
	genDictSelect('studyCode','study_type','1');
	resourceTypeMap=getTransParam('studyCode');
	applyCodeMap=getTransParam('applyCode');
	eventBind();
});

//事件绑定
function eventBind(){
	//带有分页信息的查询
	$("#queryBtn").click(pageQuery).click();
	
	//添加按钮弹出层
	$("#applyBtn").click(showAddFormDialog);
}

//表格初始化
function initTable(){
	$('#studyListTable').bootstrapTable({
		onPageChange: function (number, size) {
			pageSize = size;
			query(number, size);
		},
		onCheck:function (row) {
			rowid=row.id;
		}
	});
}

//带有分页信息的查询
function pageQuery(){
	query(1, pageSize);
};

//分页查询
function query(pageNumber, pageSize){
	var queryCondition={
		pageNumber: pageNumber, 
		pageSize: pageSize,
		params:$("#studyForm").collect()
	}
	
	$.getApiClient('/study/listOnlineApply').post(queryCondition).done(function(data){
	    $('#studyListTable').bootstrapTable('load', data.payload);
	});
};

//弹出申请内容页
function showAddFormDialog(){
	customRemoteUrlDialog('申请内容','/page/business/study/applyform',null);
}

//弹出查看详细页
function showDetailFormDialog(row){
	customRemoteUrlDialog('申请详情','/page/business/study/applyView?Id='+row.id,null);
}

//操作列
function operateFormatter(value, row, index) {	
	var operates=[];
	operates.push('<a class="edit" href="javascript:void(0)" title="查看详细"><i class="fa fa-edit"></i>查看详细</a>');
	return operates.join('');
};


operateEvents = {
	'click .edit' : function(e, value, row, index) {
		showDetailFormDialog(row);
	}
};